﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Utility.File
{
    public class Folder
    {
        #region 成员变量
        private string _Path;
        #endregion

        #region 构造函数
        public Folder()
        {
            this._Path = "";
        }

        public Folder(string path)
        {
            this._Path = path;
        }
        #endregion

        #region 属性
        #region Path
        public string Path
        {
            get
            {
                return this._Path;
            }

            set
            {
                this._Path = value;
            }
        }
        #endregion
        #endregion

        #region 公共方法
        #region Exist
        public bool Exist()
        {
            try
            {
                return System.IO.Directory.Exists(this._Path);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        #endregion

        #region Create
        public void Create()
        {
            try
            {
                System.IO.Directory.CreateDirectory(this._Path);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        #endregion

        #region MoveTo
        public void MoveTo(string destDirName)
        {
            try
            {
                System.IO.DirectoryInfo dirInfo = new DirectoryInfo(this._Path);
                dirInfo.MoveTo(destDirName);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        #endregion

        #region Delete
        public void Delete()
        {
            try
            {
                DirectoryInfo dirInfo = new DirectoryInfo(this._Path);
                dirInfo.Delete(true);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        #endregion
        #endregion
    }
}
